//
//  AuthenView.swift
//  cxd4iphone
//
//  Created by hexy on 12/26/15.
//  Copyright © 2015 hexy. All rights reserved.
//

import UIKit

class AuthenView: UIView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        
        makeUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func makeUI() {
        
//                let wrap = UIView(bgColor: xx_randomColor())
        let wrap = UIView()
        
        addSubview(wrap)
        wrap.snp_makeConstraints { (make) -> Void in
            
            make.edges.equalTo(UIEdgeInsetsMake(15, 15, -15, -15))
        }
        
        
        wrap.addSubview(authSymbolBtn)
        authSymbolBtn.snp_makeConstraints { (make) -> Void in
            
            make.top.left.equalTo(wrap)
            make.width.equalTo(xx_width(70))
        }
        
        wrap.addSubview(realNameTextField)
        realNameTextField.snp_makeConstraints { (make) -> Void in
            
            make.top.equalTo(authSymbolBtn.snp_bottom).offset(xx_height(20))
            make.left.right.equalTo(wrap)
            make.height.equalTo(xx_height(40))
            
        }
        
        wrap.addSubview(idCardTextField)
        idCardTextField.snp_makeConstraints { (make) -> Void in
            
            make.top.equalTo(realNameTextField.snp_bottom).offset(xx_height(20))
            make.left.right.equalTo(wrap)
            make.height.equalTo(xx_height(40))
            
        }
        
        wrap.addSubview(submitBtn)
        submitBtn.snp_makeConstraints { (make) -> Void in
            
            make.top.equalTo(idCardTextField.snp_bottom).offset(xx_height(30))
            make.left.right.equalTo(wrap)
            make.height.equalTo(xx_height(40))
            
        }

        
    }
    
    lazy var authSymbolBtn = UIButton(title: "未认证", titleColor: UIColor.whiteColor(), titleSize: 16, bgColor: Define.moreLightFontColor)
    
    lazy var realNameTextField = UITextField(placeholder: "请输入您的真实姓名", leftImage: UIImage(named: "auth_username")!, keyboardType:.Default)
    
    lazy var idCardTextField = UITextField(placeholder: "请输入您的身份证号", leftImage: UIImage(named: "auth_card")!, keyboardType:.PhonePad)
    
    lazy var submitBtn: UIButton = {
        
        let btn = UIButton(title: "提交信息", titleColor: UIColor.whiteColor(), titleSize: 18, bgColor: Define.blueColor)
//        btn.setBackgroundImage(UIImage.createImgaeWithColor(Define.grayColor), forState: .Disabled)
//        
//        RACSignal.combineLatest([self.loginNameTextField.rac_textSignal(), self.loginPasswdTextField.rac_textSignal()]).map { (tuple) -> AnyObject! in
//            
//            let tuple = tuple as! RACTuple
//            return Bool((tuple.first as! NSString).length > 0) && Bool((tuple.second as! NSString).length)
//            
//            }.subscribeNext { (enable) -> Void in
//                
//                btn.enabled =  (enable as! Bool)
//        }
        
        return btn
    }()
}
